/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.system.mapper;


import com.koron.system.domain.DictData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DictDataMapper {


    /**
     * insert dictData
     *
     * @param dictData
     * @return
     */
    Integer insert(@Param("dictData") DictData dictData);

    /**
     * update dictData
     *
     * @param dictData
     * @return
     */
    Integer update(@Param("dictData") DictData dictData);

    /**
     * delete dictData in batch
     *
     * @param idList
     * @return
     */
    Integer batchDetele(@Param("idList") List<String> idList);

    /**
     * query the one whose id is the given
     *
     * @param id
     * @return
     */
    DictData queryOne(@Param("id") String id);

    /**
     * query all dictData
     *
     * @param dictLabel
     * @param dictKey
     * @param start
     * @param rows
     * @return
     */
    List<DictData> queryAll(@Param("dictLabel") String dictLabel, @Param("dictKey") String dictKey, @Param("start") Integer start,
                            @Param("rows") Integer rows);

    /**
     * the number of all dictData
     *
     * @return
     */
    Integer countTotal(@Param("dictLabel") String dictLabel, @Param("dictKey") String dictKey);

    @Select("select dd.* from dict_data dd INNER JOIN dict_type dt on dd.dict_key=dt.dict_key where dt.name =#{dictName} order by dd.dict_index")
    List<DictData> queryByDictName(@Param("dictName") String dictName);

    /**
     * update dictData in batch
     *
     * @param dictDataList
     * @return
     */
    Integer batchUpdate(@Param("dictDataList") List<DictData> dictDataList);

    /**
     * 根据字典类型名称和字典数据标签查询字典数据详情
     *
     * @param dictTypeName
     * @param dictLabel
     * @return
     */
    DictData matchDictData(@Param("dictTypeName") String dictTypeName, @Param("dictLabel") String dictLabel);

}
